package com.lianjia.sh.se.kafka.client.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.lianjia.sh.se.kafka.client.constants.ProfileCons;

/**
 * 客户端统一默认配置
 * Created by yangsp1 on 16/8/2.
 */
@Configuration
public class ClientDefaultConfig {
    //获取项目的 profile
    @Value("${spring.profiles.active:test}")
    private String profile;

    @Bean
    public ClientConsumerDefaultConfig consumerDefaultConfig(){
        ClientConsumerDefaultConfig consumerDefaultConfig = new ClientConsumerDefaultConfig();
        if (ProfileCons.DEVELOPMENT.equals(profile)) {
            consumerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else if(ProfileCons.INTEGRATION.equals(profile)){
            consumerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else if(ProfileCons.PRODUCTION.equals(profile)){
            consumerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else {//默认为测试环境
            consumerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }
        return consumerDefaultConfig;
    }

    @Bean
    public ClientProducerDefaultConfig producerDefaultConfig(){
        ClientProducerDefaultConfig producerDefaultConfig = new ClientProducerDefaultConfig();
        if (ProfileCons.DEVELOPMENT.equals(profile)) {
            producerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else if(ProfileCons.INTEGRATION.equals(profile)){
            producerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else if(ProfileCons.PRODUCTION.equals(profile)){
            producerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }else {//默认为测试环境
            producerDefaultConfig.setBootstrapServers("192.168.3.59:9092");
        }
        return producerDefaultConfig;
    }
}
